Self-hosted n8n on render.com
2024-09-30
1. Forking n8n GitHub Repo and Deploying on Render.com
Steps to Fork and Deploy:
-
Fork the n8n GitHub Repository:
- Head to the official n8n GitHub repo and click "Fork".
- This will allow you to maintain a version of the code that you can modify as needed.
-
Create a Web Service on Render.com:
- Log in to your Render dashboard.
- Click on "New +" and select Web Service.
- Connect your GitHub account and select the forked n8n repository.
- Choose a branch (e.g.,
main
) to deploy. - Select Docker as the runtime environment, as n8n runs in a Docker container.
-
Instance Type:
- Start with at least a Standard instance (512MB RAM, 0.5 CPU), which can be scaled up based on your needs.
-
Docker Commands:
-
In the Start Command field, input:
bash
Copy code
n8n start
-
No build command is required since Docker will handle that.
-
-
Set Environment Variables:
-
Add the following key-value pairs in the Render dashboard:
bash
Copy code
DB_TYPE: postgresdb DB_POSTGRESDB_HOST: <your-database-host> DB_POSTGRESDB_PORT: 5432 N8N_ENCRYPTION_KEY: <random-long-string> N8N_HOST: 0.0.0.0 N8N_PORT: ${PORT} WEBHOOK_URL: https://<your-app-name>.onrender.com
-
Make sure to mark sensitive keys (like API tokens) as secrets for enhanced security.
-
-
Deploy the Service:
- Click "Create Web Service" and Render will start building your service.
- Monitor the logs for any issues and ensure your n8n instance is running smoothly.
2. Deploying n8n Using Docker Image on Render.com
If you prefer using Docker images for deployment, follow this alternative method:
Steps to Use Docker Image:
-
Use the Prebuilt Docker Image:
- Instead of forking the repo, use a prebuilt n8n Docker image.
-
Create a New Web Service:
- On Render, create a new Web Service and select Docker as the runtime environment.
- You can upload your own Dockerfile or reference the n8n image from DockerHub.
-
Configure Persistent Storage:
-
Ensure persistent storage for the
.n8n
folder:bash
Copy code
/home/node/.n8n
-
This ensures workflow and credential data persist between restarts.
-
-
Start Command:
-
Same as the GitHub method, use the following start command:
bash
Copy code
n8n start
-
3. Additional Configuration
Postgres Setup:
-
Use Postgres for better persistence than SQLite. Update environment variables with your Postgres database credentials:
bash
Copy code
DB_TYPE: postgresdb DB_POSTGRESDB_DATABASE: <db_name> DB_POSTGRESDB_USER: <db_user> DB_POSTGRESDB_PASSWORD: <db_password>
Securing Webhooks:
- Update the
WEBHOOK_URL
environment variable to point to your app's Render URL (e.g.,https://your-app-name.onrender.com
).
4. Advanced Tips
- Auto-Deploy: Enable auto-deploy on Render to automatically redeploy your n8n instance when you push changes to the GitHub repository.
- Custom Domains: Set up a custom domain for your n8n instance via the Render dashboard if needed.
For more detailed information, visit: